<?php
// param $names (mixed) - An array or a text file which contains the destination file names on each line.
// If you include file extensions above, make sure to set $keep_ext to false.
// param $source_file (string) - A source file name (with extension)
// param $destination (string) - Destination folder (without trailing slash)
// param $keep_ext (boolean) - To keep or not to keep the source extension.
// Useful if you set the extensions in $names.
function duplicateFiles($names, $source_file, $destination = false, $keep_ext = true){
	if(!is_array($names) && !is_file($names)) return FALSE; // It's not a file or array
        elseif(is_file($names)) $names = file($names); // It's a file
        else; // It's an array
        
        if(!$names) return FALSE; // Empty array passed or file with destination names empty
 
        $source = $source_file;
        $response = array();
        $destination = (!$destination) ? './' : $destination.'/';
        
        if($keep_ext){
            $ext = explode('.', $source);
            $ext = end($ext);
            if($ext) $ext = '.'.$ext;
        }

        foreach($names as $name){
                $dest = $destination.trim($name).$ext;
                $copy = @copy($source, $dest);
                if($copy) $response[$name] = TRUE;
                else $response[$name] = FALSE;
        }
        return $response;
}

print_r(duplicateFiles('keywords.txt', 'sourcefile.pdf', './output'));
?>